import matplotlib.pyplot as plt
import numpy as np

# Generate a Gaussian N=8 ensemble
rng = np.random.default_rng(0)

numJtests = 1000000
Jtests = rng.normal(scale=0.465, size=(numJtests,8,8))
Jtestsym = np.tril(Jtests) + np.tril(Jtests,-1).transpose((0,2,1)) # symmetrize while keeping the same distribution for each element

testevs = np.array([np.linalg.eigvalsh(J) for J in Jtestsym])

# Eigenvalue spectrum
h,b,_ = plt.hist(testevs.flatten(),bins=100,density=True)
bmid = (b[1:] + b[:-1])*0.5

# df_ev = pd.DataFrame(data = {'bin center': bmid,
#                              'probability density': h})
# df_ev.set_index('bin center').to_csv(datarepodir + 'FigS22_GOE_ev.csv')


# Eigenvalue splitting
testsplits = np.diff(testevs,axis=1)
h,b,_ = plt.hist(testsplits.flatten(),bins=100,density=True)
bmid = (b[1:] + b[:-1])*0.5

# df_split = pd.DataFrame(data = {'bin center': bmid,
#                                 'probability density': h})
# df_split.set_index('bin center').to_csv(datarepodir + 'FigS22_GOE_split.csv')